package com.yanxml.spring.history.v3.demo6_conditional_on.condition_on;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ConditionOnClass implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        // 根据我们特定的业务需求来决定是否注入对应的对象
        try {
//            Class.forName("com.yanxml.spring.history.v3.demo6_conditional_on.condition_on.Judge");
            Class.forName("com.yanxml.spring.history.v3.demo6_conditional_on.condition_on.Judge2");
            return true;
        } catch (ClassNotFoundException e){
            e.printStackTrace();
        }
        return false;
    }
}
